package com.nytd.demo.controller;

import com.nytd.demo.model.User;
import com.nytd.demo.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @Autowired
//    @Qualifier("u1")
    @Resource(name = "u1")
    private User user;

//    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

//    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void hello(){
        System.out.println("hello UserController");
        userService.sayHi("张三");
        System.out.println(user);
    }
}
